/**************************************************************************
 * @doc EMV
 * @module EMVsrc |  
 * Source code for the EMV handling functions.
 *
 * Product         :   SoftPay 2000 (Global Payment Methodology).
 * <nl>Developer   :   SoftPay Development Team ASPAC ADC.
 * <nl>Notes       :
 *
 * @head3 EMV Functions | 
 * @index | EMV
 * @end
 *
 * Copyright (c) 1996-2005 by VeriFone Inc. All rights reserved.
 * 
 * No part of this software may be used, stored, compiled, reproduced,
 * modified, transcribed, translated, transmitted, or transferred, in any form 
 * or by any means whether electronic, mechanical, magnetic, optical, 
 * or otherwise, without the express prior written permission of VeriFone, Inc.
 *
 * Revision History
 * ------------------------------------------------------------------------
 *
 *
 ********************************************************************************/


void vdAddEMVFunctions( void );

/*  Function that called by other Softpay function */
int inEMVCardReadOperation (TRANSACTION_OBJECT *pobTran, PFI_TO pinValSwiped, int *pinResult);
int inEMVEnterCardData (TRANSACTION_OBJECT *pobTran);
int inEMVValidateICCCard (TRANSACTION_OBJECT *pobTran);
int inEMVDemo(TRANSACTION_OBJECT *pobTran);

/* EMV operation flow function */
int inEMVAPIInit(TRANSACTION_OBJECT *pobTran);
int inEMVAPITransInit(TRANSACTION_OBJECT *pobTran);
int inEMVAPICheckFallback(TRANSACTION_OBJECT *pobTran);
int inEMVForceOnline(TRANSACTION_OBJECT *pobTran);
int inEMVCheckForceOnline(TRANSACTION_OBJECT *pobTran);

/* EMV transaction flow function */
int inEMVAPIRemoveCard(TRANSACTION_OBJECT *pobTran);
int inEMVAPIPRandTRM(TRANSACTION_OBJECT *pobTran);
int inEMVAPICardholderVerification(TRANSACTION_OBJECT *pobTran);
int inEMVAPIFirstGenerateAC(TRANSACTION_OBJECT *pobTran);
int inEMVAPIUseHostDataFlow(TRANSACTION_OBJECT *pobTran);
int inEMVAPIDataAuthentication(TRANSACTION_OBJECT *pobTran);
int inEMVUpdateSplitSales(TRANSACTION_OBJECT *pobTran);
int inEMVAPISetOffline (TRANSACTION_OBJECT *pobTran);
int inEMVAPIGetBaseAmount(TRANSACTION_OBJECT *pobTran);
int inEMVAPIPrepareBatch(TRANSACTION_OBJECT *pobTran);

int inEMVSetNonChip(TRANSACTION_OBJECT *pobTran); //KiaSoon

/* EMV Tags/Debug report printing */
int inEMVLogReportOperation(TRANSACTION_OBJECT *pobTran);
int inPrintEMVLogData(char* szTAG, char* szName, int inTAGLen );
void vdEMVDebugPrint(char* pszStr1, unsigned char* pstValueStr, int inDataLen);
int inEMVDebugPrintReport(TRANSACTION_OBJECT *pobTran);
void vdFormatStringForPrint(unsigned char * ucSrcBuf, unsigned char * ucDestBuf,  int inSrcLen);
int inGetTerminalDecision(void);
int inEMVGetIssuerDataFromResponse(TRANSACTION_OBJECT *pobTran);
extern int inEMVAddDataToBatch(TRANSACTION_OBJECT *pobTran);
extern int inEMVCheckTransAllwd(TRANSACTION_OBJECT *pobTran);
extern int inEMVCheckForceOnlineTime(TRANSACTION_OBJECT *pobTran);
extern int inEMVPrintReceiptTop(TRANSACTION_OBJECT *pobTran);

int inPrintWatchPacket(unsigned char *pucMessage, int inLen, char*szPrintBuffer);

extern int inCPACDoReversal(TRANSACTION_OBJECT* pobTran,int inISOSendSize) ;
int inUpdateReversalTVR(void);
extern int inImamEMVFullFallback(void) ;
extern int get_env_x(char *param, int n, char *buff);

extern void vdCPACDispRespMsg(TRANSACTION_OBJECT* pobTran) ;
extern void LOG_PRINT_HEX(unsigned char* buf, int size);
extern void vdGetReversalFileName(char* pszFName,int inHostIndex);

